//
//  FSLPageView.swift
//  FSLText
//
//  Created by 我演示 on 2019/11/2.
//  Copyright © 2019 ALLSall. All rights reserved.
//

import UIKit

/**
 如果使用这种class 则不能被类以及enum 遵守
 */

class FSLPageView: UIView {

    
    fileprivate var titles : [String]
    fileprivate var childVcs : [UIViewController]
    fileprivate var parentVc : UIViewController
    fileprivate var style : FSLTitleStyle
    
    fileprivate var titlleView : FSLTitleView!
    init (frame: CGRect , titles : [String] , childVcs : [UIViewController] ,parentVc : UIViewController , style : FSLTitleStyle ) {
        self.titles = titles
        self.childVcs = childVcs
        self.parentVc = parentVc
        self.style = style
        
        super.init(frame: frame)
        
        setUpUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}


extension FSLPageView {
    fileprivate func setUpUI() {
        
        }
    private func setUpTitleView() {
        let titleFrame = CGRect(x: 0, y: 0, width: bounds.width, height: style.titleHeight)
        
        titlleView = FSLTitleView(frame: titleFrame, titles: titles, style: style)
        addSubview(titlleView)
        titlleView.backgroundColor = UIColor.gray
    }
    private func setUpContentView() {
        //1: 取出类的一定是可选性
        let contentFrame = CGRect(x: 0, y: style.titleHeight, width: bounds.width, height: bounds.height - style.titleHeight)
        let contentView = FSLContentView(frame: contentFrame, childVcs: childVcs, parentVc: parentVc)
        
        addSubview(contentView)
        
        //2:  让contentView 成为代理
        titlleView.delegate = contentView 
        
        contentView.delegate = titlleView as! FSLContentViewDelegate
        
        
    }
}
